package WaiBao;

import java.util.Arrays;

public class ZhangZiChuan {
    public static void main(String[] args) {
        String[] name = {"张国立(班长)", "张家辉(副班长)", "小李(学习委员)", "赵凯凯(体育委员)", "李道华", "洪小刚", "庾澄庆", "洪金宝", "梁朝伟", "周传雄", "华晨宇", "吕子乔",
                "白敬亭", "杜聿明", " 杨超", "李大胖", "张小瘦", "孙志愿", "牛大胆", "张勇", "王保国", "李大文", "王凯", "王子文", "谢娜", "杜海涛", "肖战", "黄子韬",
                "邓伦", "张子川(学生)"};//考生本人: 张子川(学生)
        int[] age = {18, 19, 20, 19, 18, 20, 19, 21, 19, 19, 18, 18, 18, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 20, 18, 20, 20};//考生本人年龄:20
        double[] B1 = {68, 82, 64, 60, 69, 69, 78, 89, 80, 80, 91, 87, 85, 89, 65, 68, 99, 99, 96, 88, 92, 91, 95, 65, 75, 74, 94, 74, 78, 92};
        double[] B2 = {77, 85, 99, 76, 78, 77, 78, 69, 90, 70, 90, 77, 66, 95, 65, 65, 76, 99, 66, 98, 72, 71, 95, 86, 75, 88, 84, 94, 80, 93};
        double[] B3 = {74, 96, 80, 95, 79, 69, 78, 69, 80, 80, 93, 87, 85, 65, 65, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 84, 73, 91, 69, 94};


        double CC;//代表每个学生的总分
        double HH;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//           CC = B1[i] + B2[i] + B3[i];
//            HH = (CC * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + CC);
//            System.out.println(name[i] + "的平均分为:" + HH);
//        }
//
//        double RR = 0, AA = 0;
//        double[] CUNFANG = new double[30];
//        for (int i = 0; i < 30; i++) {
//            RR = B1[i] + B2[i] + B3[i];
//            AA= (RR * 1.0) / 3;
//            CUNFANG[i] = AA;
//        }
//
//        for (int i = 0; i < CUNFANG.length - 1; i++) {
//            for (int j = 0; j < CUNFANG.length - i - 1; j++) {
//                if (CUNFANG[j] < CUNFANG[j + 1]) {
//                    double tep = CUNFANG[j];
//                    CUNFANG[j] = CUNFANG[j + 1];
//                    CUNFANG[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(CUNFANG[i]);
//        }
//
//
//
        double Q1 = 0, Q2 = 0, Q3 = 0;//计算每门课的平均分
        double k1 = 0, k2 = 0, k3 = 0;//计算每门课标准差
        double S1 = 0, S2 = 0, S3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i < B1.length; i++) {
            he += B1[i];
        }
        Q1 = (he * 1.0) / 30;
        System.out.println("生物化学的班级平均分为:" + Q1);
        double Sum = 0;
        for (int i = 0; i < B2.length; i++) {
            Sum += B2[i];
        }
        Q2 = (Sum * 1.0) / 30;
        System.out.println("微生物学的班级平均分为:" + Q2);
        double sum = 0;
        for (int i = 0; i < B3.length; i++) {
            sum += B3[i];
        }
        Q3 = (sum * 1.0) / 30;
        System.out.println("人体组织解剖学的班级平均分为:" + Q3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < B1.length; i++) {
            c1 += (B1[i] - Q1) * (B1[i] - Q1);
        }
        k1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:" + k1);
        for (int i = 0; i < B2.length; i++) {
            c2 += (B2[i] - Q2) * (B2[i] - Q2);
        }
        k2 = Math.sqrt(c2*1.0/30);
        System.out.println("微生物学的班级标准差为:" + k2);

        for (int i = 0; i < B3.length; i++) {
            c3 += (B3[i] - Q3) * (B3[i] - Q3);
        }
        k3 = Math.sqrt(c3*1.0/30);
        System.out.println("人体组织解剖学的班级标准差为:" + k3);



        Arrays.sort(B1);
        Arrays.sort(B2);
        Arrays.sort(B3);
        S1 = (B1[15] + B2[14]) * 1.0 / 2;
        S2 = (B2[15] + B2[14]) * 1.0 / 2;
        S3 = (B3[15] + B3[14]) * 1.0 / 2;
        System.out.println("生物化学的中位数为:" + S1);
        System.out.println("微生物学的中位数为:" + S2);
        System.out.println("人体组织解剖学的中位数为:" + S3);



    }
}
